﻿/******************************************************************************
* File description: licenseManager.h
* Function: 授权码
* Current Version: 1.0.0
* Author: JNN
* Date: 2025-07-01
*  -----
*  Copyright by 博坤生物 .
 *****************************************************************************/


#ifndef LICENSEMANAGER_H
#define LICENSEMANAGER_H

#include <QProcess>
#include <QDebug>
#include <QObject>
#include <QSettings>
#include <QDateTime>
#include <QTimer>
#include "logHelper/debugLog.h"
#include "crypto.h"
#include <QtNetwork>

#ifdef Q_OS_WIN
#include <windows.h>
#include <intrin.h>
#endif

class LicenseManager : public QObject
{

    Q_OBJECT

private:

    LicenseManager();
    ~LicenseManager();

public:
    static LicenseManager& I();


signals:
    void showLicensePage();
    void showTimeExceptionPage();

public:
    Q_INVOKABLE QString getUUID();

    // Settings操作
    Q_INVOKABLE bool         registSystemLicense(QString cipherText);
    Q_INVOKABLE bool         checkSystemLicense();          // 检测当前软件权限
    Q_INVOKABLE QString      getSystemLicense();            // 获取当前许可信息
    Q_INVOKABLE void         clearSystemLicense();          // 清除注册信息
    Q_INVOKABLE QVariantMap  getSystemLicenseInfo();

private slots:
    void        updateTimeStamp();

private:

    QVariantMap license2Info(QString cipherText);
    bool        checkLicense(QString cipherText);

    QString     get_mac_id();
    QString     get_cpu_id();

private:

    Crypto*     _crypto;
    QTimer*     _timer;

    QSettings*  _settings;

    QString     _organization = "bokun";
    QString     _application = "NIDCS2";


};

#endif // LICENSEMANAGER_H
